package cn.cycleif.app.controller;

import cn.cycleif.app.service.NotificationService;
import cn.cycleif.util.R;
import cn.dev33.satoken.annotation.SaCheckLogin;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Date: 25/2/17-14:16
 * @Desc:
 */
@RequestMapping("/api/notification")
@RestController
@SaCheckLogin
@Tag(name = "通知", description = "通知相关接口")
public class NotificationController {

  @Autowired
  private NotificationService notificationService;

  @GetMapping("/list")
  @Operation(summary = "获取当前登录用户的通知")
  public R<Object> getNotification(
      @RequestParam("type") String type
  ) {
    return notificationService.getPage(type);
  }

  @GetMapping("/markRead")
  @Operation(summary = "标记通知为已读")
  public R<String> markNotificationRead(
      @RequestParam("type") String type
  ) {
    return notificationService.markRead(type);
  }

  @GetMapping("/count")
  @Operation(summary = "获取当前登录用户的通知数量")
  public R<String> getNotificationCount() {
    return notificationService.getCount();
  }
}
